﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel.Security;

namespace Pg.BioMedics.ASR.Client
{
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                using (WebServices.ASRServiceClient client = new WebServices.ASRServiceClient())
                {                 
                    client.ClientCredentials.UserName.UserName = userNameTextBox.Text;
                    client.ClientCredentials.UserName.Password = passwordTextBox.Text;

                    WebServices.Task[] waitingTasks = client.GetWaitingTasks();

                    ClientCredentialsCache.Create(client.ClientCredentials.UserName);                    
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
